/**
 * Created by Administrator on 2016/12/5.
 */
(function ($) {
   $(document).ready(function () {
      addListener();
       //ie兼容placeholder
       if( !('placeholder' in document.createElement('input')) ){

           $('input[placeholder],textarea[placeholder]').each(function(){
               var that = $(this),
                   text= that.attr('placeholder');
               if(that.val()===""){
                   that.val(text).addClass('placeholder');
               }
               that.focus(function(){
                       if(that.val()===text){
                           that.val("").removeClass('placeholder');
                       }
                   })
                   .blur(function(){
                       if(that.val()===""){
                           that.val(text).addClass('placeholder');
                       }
                   })
           });
       }
       //页面事件监听
       function addListener() {
           // 小提示
           $('.table_tip').on('mouseover',function () {
               $(this).find('.tip').toggle();
           }).on('mouseout',function () {
               $(this).find('.tip').toggle();
           });
           //价格编辑
           $(".edit").on('click',function (e) {
               if(e.target.tagName=='SPAN'){
                   $(this).find('div').css('display','block');
               }else if(e.target.tagName=='BUTTON'){
                   if($(this).find('input').val()!=''){
                       $(this).siblings('.price').text($(this).find('input').val()) ;
                   }
                   $(this).find('div').css('display','none');
               }
           })
           //备注框字数提示
           $("#remarks").on('keyup',function (e) {
               var num='最多还可输入'+(500-$(this).val().length)+'字';
               $(this).siblings('.remarks_tip').text(num)
           })
       }
   })
})(jQuery);